package com.zd.springsecuritydemo.response;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author ZhangDong
 * @date 2024/1/7 11:23
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
@NoArgsConstructor
@AllArgsConstructor
@Data
public class ResponseResult<T> {

    private Integer code;
    private String msg;
    private T data;

    public ResponseResult(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public ResponseResult(Integer code, T data) {
        this.code = code;
        this.data = data;
    }

    public ResponseResult(T data) {
        this.data = data;
    }

    public static ResponseResult fail(String message) {
        return new ResponseResult(500, message);
    }

    public static ResponseResult fail(Integer code ,String message) {
        return new ResponseResult(code, message);
    }
}
